package Test3;
/**
 *
 * @author 29284
 * @since 2024/11/29 21:21
 */
public class GirlFriendTest {
    public static void main(String[] args) {
        GirlFriend [] arr = new GirlFriend[4];
        GirlFriend g1=new GirlFriend("佩奇",18,"女","踩泥坑");
        GirlFriend g2=new GirlFriend("美羊羊",20,"女","做美食");
        GirlFriend g3=new GirlFriend("暖羊羊",21,"女","画画");
        GirlFriend g4=new GirlFriend("花园宝宝",18,"女","睡觉");
        arr[0]=g1;
        arr[1]=g2;
        arr[2]=g3;
        arr[3]=g4;
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i].getAge();
        }
        int avg=sum/arr.length;
        System.out.println("女朋友的平均年龄 "+avg+" 岁");
        int count=0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i].getAge()<avg) {
                System.out.println(arr[i].getName()+" "+arr[i].getAge()+" "+arr[i].getGender()+" "+arr[i].getHobby());
                count++;
            }
        }
        System.out.println("低于平均年龄的女朋友有 "+count+" 个");
    }
}
